#include <iostream>
#include "card_generator.h"
#include "card_table.h"
using namespace dymy;
using namespace std;
std::ostream &operator<<(std::ostream &os, const std::vector<card_t> &cards);
std::ostream &operator<<(std::ostream &os, const std::vector<std::vector<card_t>> &cards);
std::ostream &operator<<(std::ostream &os, const multiple_card_t &cards);
ostream &operator<<(ostream &os, const table::Person &p);
ostream &operator<<(ostream &os, const dymy::card::AllCards_t &cards);
int main(int, char **)
{
    std::cout << "generator_test:" << std::endl;
    constexpr size_t aN = 54; //一副牌54张
    constexpr size_t pN = 3;  //一共三个玩家
    constexpr size_t eN = 17; //每个玩家17张牌
    constexpr size_t hN = 3;  //三张底牌

    using Person = table::Person;
    //创建三个人
    std::array<std::unique_ptr<Person>, pN> person = {std::make_unique<Person>(1, "user1"),
                                                      std::make_unique<Person>(2, "user2"),
                                                      std::make_unique<Person>(3, "user3")};

    //底牌数据
    std::vector<card_t> hole;

    using CardGenerator = generator::CardGenerator<Person, aN, pN, eN, hN>;

    //创建一副牌
    auto all_cards = card::MakeAllCards();

    //创建一个生成器
    CardGenerator g(std::make_shared<CardGenerator::AllCards>(std::move(all_cards)));

    //开始为每个人生成卡牌和底牌
    g.MakeCards(person, hole);

    for (int i = 0; i < hole.size(); ++i)
    {
        std::cout << static_cast<int>(card::decode_card_num(hole[i])) << ' ';
    }
    std::cout << std::endl;
    for (auto i = 0; i < person.size(); ++i)
    {
        auto &p = person[i];
        auto &cards = p->cards;
        std::cout << p->user_name << ':' << cards << std::endl;
    }
    return 0;
}
std::ostream &operator<<(std::ostream &os, const dymy::card_t &c)
{
    return os << static_cast<int>(c) << "(" << static_cast<int>(dymy::card::decode_card_num(c)) << ")";
}

std::ostream &operator<<(std::ostream &os, const multiple_card_t &cards)
{
    for (auto begin = cards.cbegin(); begin != cards.cend(); ++begin)
    {
        os << *begin << ' ';
    }
    return os;
}
